
<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>{$title}</title>
    <!--加载CSS-->
    {load href="/static/index/css/bootstrap.min.css"}
    {css href="/static/index/reset.css"}
    {css href="/static/index/css/toastr.min.css"}
                                       <!---->
                                    <!--电影表-->
                                       <!---->
</head>
<body>
<h1>{$title}</h1>
{extend name="index/index" /}
{block name="main"}
<div class="container">
    <div class="col-md-12 bg-primary p20">

        <hr>
        <a href="{:url('admin/index/shouye')}" class="btn btn-default">后台主页</a>
        <!--<a href="{:url('rest/user/create')}" class="btn btn-default">添加页</a>-->
    </div>
    <div class="clearfix"></div>

    {block name="main"}
    <div class="row mt50">
        <div class="col-md-12">
            <table class="table table-hover bg-info ">
                <tr >
                    <th>id</th>
                    <th>moviename</th>
                    <th>poster</th>
                    <th>movietype</th>
                    <th>playingtype</th>
                    <th>duration</th>
                    <th>rating</th>
                    <th>description</th>
                    <th>playingtime</th>
                    <th>
                        <a href="{:url('admin/movie/create')}" class="btn btn-primary                           btn-xs">添加</a>
                    </th>

                </tr>
                {volist name="list" id="v"  }
                <tr>
                    <td>{$v['id']}</td>
                    <td>{$v['moviename']}</td>
                    <td>{$v['poster']}</td>
                    <td>{$v['movietype']}</td>
                    <td>{$v['playingtype']}</td>
                    <td>{$v['duration']}</td>
                    <td>{$v['rating']}</td>
                    <td>{$v['description']}</td>
                    <td>{$v['playingtime']}</td>


                    <td class="col-md-1">
                        <!--<a href="{:url('rest/user/readpage', ['id'=>$v['id']])}" class="btn btn-default btn-xs">查看信息(页)</a>-->
                        <!--<button data-id="{$v['id']}" class="btn btn-default btn-xs show-btn" data-toggle="modal" data-target="#myModal">查看信息(框)</button>-->

                        <button data-id="{$v['id']}" class="btn btn-danger btn-xs del-btn">删除</button>
                    </td>
                </tr>

                {/volist}
            </table>
        </div>

    </div>
</div>





<!--加载JS-->
{js href="/static/index/js/jquery.min.js"}
{js href="/static/index/js/bootstrap.min.js"}
{js href="/static/index/js/toastr.min.js"}



<script>
    //-------------------------------用户删除-------------------------------------------//
    $(function () {
        // 触发用户删除
        $('.del-btn').click(function () {
            var ac_id = $(this).attr('data-id');
            console.log('删除的ID为:', ac_id);

            if (confirm('您确定要 [ 删 除 ] 该用户么?')) {
                var obj = $(this).parents('tr');
             //console.log(obj);
                delAjax(ac_id, obj);// 执行删除操作
            }
        });

    });



    // 执行AJAX删除的操作
    function delAjax(id, obj) {
         //console.log(id);
        $.ajax({
            type: 'delete',
            url: '/movies/' + id,
            dateType: 'json',
            success: function (data) {
                if (data.status) {
                    // console.log(data);
                    // console.log('删除成功');
                    toastr.success(data.info);
                    //  将指定条目 节点删除
                    obj.remove();
                } else {
                    //console.log('删除失败');
                    toastr.error(data.info,'FBI WARNING: ');
                }
            },
            error: function () {
                // AJAX执行失败
                alert('ajax操作失败');
            }
        });
    }
    //-----------------------------用户删除end----------------------------------------//
</script>

{/block}
</body>
</html>